package com.tpo.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

 

import org.springframework.stereotype.Service;

import com.tpo.base.GridRequest;
import com.tpo.base.ResultGrid;
import com.tpo.dao.Tpo_roleMapper;
import com.tpo.model.Tpo_role;
import com.tpo.model.bean.RoleGrid;
import com.tpo.service.RoleService;
@Service("roleservice")
public class RoleServiceImpl implements RoleService{

	@Override
	public ResultGrid<Tpo_role> getrolelist(RoleGrid record) {
		record.setFrom();
		record.setTo();
		
		if(record.getKey()==null||record.getKey().equals("")){
			record.setKey(null);
		}else{
			record.setKey(record.getKey()+"%" );
		}
		
	    List<Tpo_role> rolelist=rolemapper.getRoleList(record);//得到分页的数据
	    int rowcount=rolemapper.getRolecount(record);//获得总记录数
	    
	    ResultGrid<Tpo_role> ret=new ResultGrid<Tpo_role>(); 
	    ret.setTotal(rowcount/record.getRows()+1);
	    ret.setRows(rolelist); 
	    ret.setPage(record.getPage()); 
	    ret.setRecords(rolemapper.getRolecount(record)); 
	    return ret;
	}
	
	
	@Autowired
	private Tpo_roleMapper rolemapper;
}
